﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace biolit_config
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class DownloadLocation : Window
    {
        public DownloadLocation()
        {
            InitializeComponent();
        }

        private void DownloadButton_Click(object sender, RoutedEventArgs e)
        {
            ConfigSettings cs = Biolit_Settings.Settings;
            if (!String.IsNullOrEmpty(DownloadName.Text) && !String.IsNullOrEmpty(DownloadURL.Text))
            {
                List<OntologyDownloadLocation> dd = new List<OntologyDownloadLocation>();
                dd = cs.AvailableDownloadURLs.ToList();
                OntologyDownloadLocation OntologyDownloadLoc = new OntologyDownloadLocation(DownloadName.Text, DownloadURL.Text);
                dd.Add(OntologyDownloadLoc);
                cs.DownloadURLLocations = dd.ToArray();
                cs.SelectedDownloadURL.Name = DownloadName.Text;
                cs.SelectedDownloadURL.URL = DownloadURL.Text;
                Biolit_Settings.Settings.AvailableDownloadURLs = dd.ToArray();
                Biolit_Settings.StoreSettings();
                this.DialogResult = true;
            }
        }
    }
}
